/**
 * @author zhouyanxiang
 * @since  2020-11-2020/11/23-10:44
 */
public class Main {

    interface MathOperation {
        /**
         * 对两个int类型的数据进行计算
         * @param a 第一个参数
         * @param b 第二个参数
         * @return 一个int类型
         */
        int operation(int a,int b);
    }

    interface GreetingService {
        /**
         * 传入一个String类型的信息
         * @param msg 信息
         */
        void sayMessage(String msg);
    }

    private int operate(int a, int b, MathOperation mathOperation) {
        return mathOperation.operation(a,b);
    }

    public static void main(String[] args) {
        Main m = new Main();

        // 类型声明 MathOperation addition = (int a, int b) -> a + b;
        MathOperation addition = Integer::sum;

        // 不用类型声明
        MathOperation subtraction = (a,b) -> a - b;

        // 大括号中的返回语句
        //MathOperation multiplication = (int a,int b) ->{return a + b;};
        MathOperation multiplication = Integer::sum;

        // 没有大括号及返回语句
        MathOperation division = (int a, int b) -> a / b;

        System.out.println("10 + 5 = " + m.operate(10,5,addition));
        System.out.println("10 - 5 = " + m.operate(10,5,subtraction));
        System.out.println("20 * 10 = " + m.operate(20,10,multiplication));
        System.out.println("20 / 5 = " + m.operate(20,5,division));

        GreetingService greetingService = msg -> System.out.println("Hello " + msg);
        greetingService.sayMessage("Java");
        greetingService.sayMessage("Python");
        greetingService.sayMessage("Go");
    }

}
